<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <script src="angularjs/angular.min.js"></script>
    <title>原理</title>
</head>
<body ng-app="app">
    <div ng-controller="ctrl">
        <h3>{{name}}</h3>
        <h3>{{site}}</h3>
        <input type="text" ng-model="name"/>
    </div>
    <script>
        angular.module("app",[])
                .controller("ctrl", function ($scope) {

                    $scope.$watch("name",function(name){
                        console.log(name);
                        if(name == "forjs"){
                            $scope.site = "http://forjs.org";
                        }else{
                            $scope.site = "no site";
                        }
                    })
                })
    </script>
</body>
</html>